<template>
    <view class="container data-v-408d7d64">
        <view class="carts data-v-408d7d64">
            <uni-swipe-action-item
                :autoClose="false"
                @__l="__l"
                class="data-v-408d7d64"
                :vueId="'6a21c8ac-1-' + index"
                :vueSlots="['default', 'right']"
                v-for="(item, index) in $root.l0"
                :key="index"
            >
                <view @tap="__e" class="right-c data-v-408d7d64" :data-event-opts="[['tap', [['deleteAction', [index]]]]]" slot="right">
                    <text class="data-v-408d7d64">删除</text>
                </view>

                <view class="cart-item flex flex-vcenter data-v-408d7d64">
                    <view @tap="__e" class="select-icon data-v-408d7d64" :data-event-opts="[['tap', [['handleSelectedChange', ['$event']]]]]" :data-index="index">
                        <radio :checked="item[$orig].is_selected" class="data-v-408d7d64" color="#ffcc00"></radio>
                    </view>
                    <view class="item data-v-408d7d64">
                        <image
                            @tap="__e"
                            class="thumb data-v-408d7d64"
                            :data-event-opts="[['tap', [['toProductPage', ['$0'], [[['list', 'id', item[$orig].id]]]]]]]"
                            :src="item[$orig].sku.thumb"
                        ></image>
                        <view class="right data-v-408d7d64">
                            <view @tap="__e" class="data-v-408d7d64" :data-event-opts="[['tap', [['toProductPage', ['$0'], [[['list', 'id', item[$orig].id]]]]]]]">
                                <view class="category data-v-408d7d64">{{ item[$orig].sku.sub_title }}</view>
                                <view class="title data-v-408d7d64">{{ item[$orig].sku.title }}</view>
                                <view class="attr-c data-v-408d7d64">{{ '' + item.f0 + '' }}</view>
                                <view class="price-c data-v-408d7d64">
                                    <view class="price data-v-408d7d64">
                                        <price-display
                                            @__l="__l"
                                            class="data-v-408d7d64"
                                            :info="item[$orig].sku"
                                            :vueId="'6a21c8ac-2-' + index + ',' + '6a21c8ac-1-' + index"
                                        ></price-display>
                                    </view>
                                </view>
                            </view>
                            <view class="count-c data-v-408d7d64">
                                <view class="buy-count data-v-408d7d64">
                                    <i-input-number
                                        @__l="__l($event, { eventOpts: [['^change', [['totalChange', ['$event', index]]]]] })"
                                        @change.stop.prevent="__e($event, { eventOpts: [['^change', [['totalChange', ['$event', index]]]]] })"
                                        class="data-v-408d7d64"
                                        :data-event-opts="[['^change', [['totalChange', ['$event', index]]]]]"
                                        size="small"
                                        :value="item[$orig].temp_total"
                                        :vueId="'6a21c8ac-3-' + index + ',' + '6a21c8ac-1-' + index"
                                    ></i-input-number>
                                </view>
                            </view>
                        </view>
                    </view>
                </view>
            </uni-swipe-action-item>
            <view class="data-v-408d7d64" v-if="!$root.g0">
                <view class="data-v-408d7d64" style="height: 1rpx"></view>
                <no-data @__l="__l" class="data-v-408d7d64" vueId="6a21c8ac-4"></no-data>
            </view>
        </view>
        <view class="footer-actions space-between flex-vcenter safe-area-bottom data-v-408d7d64">
            <view @tap="__e" class="select-all flex flex-vcenter data-v-408d7d64" :data-event-opts="[['tap', [['handleSelectedAll', ['$event']]]]]">
                <radio :checked="selectedAll" class="data-v-408d7d64" color="#ffcc00"></radio>
                <text class="data-v-408d7d64">全选</text>
            </view>
            <view class="side-right flex flex-vcenter data-v-408d7d64">
                <view @tap="__e" class="buy-button data-v-408d7d64" :data-event-opts="[['tap', [['payByCart', ['$event']]]]]">
                    去结算
                    <price-display @__l="__l" class="data-v-408d7d64" :info="totalPrice" vueId="6a21c8ac-5"></price-display>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
import uniSwipeActionItem from '@/uni_modules/uni-swipe-action/components/uni-swipe-action-item/uni-swipe-action-item';
import priceDisplay from '@/components/PriceDisplay/PriceDisplay';
import noData from '@/components/NoData/NoData';
import iButton from '@/components/Button/index';
import iInputNumber from '@/components/InputNumber/index';
import tabBar from '@/components/TabBar/tabBar';
(global.webpackJsonp = global.webpackJsonp || []).push([
    ['pages/cart/index'],
    {
        '145c': function (t, e, n) {
            'use strict';

            n.d(e, 'b', function () {
                return o;
            });
            n.d(e, 'c', function () {
                return r;
            });
            n.d(e, 'a', function () {
                return i;
            });
            var i = {
                uniSwipeActionItem: function () {
                    return Promise.all([n.e('common/vendor'), n.e('uni_modules/uni-swipe-action/components/uni-swipe-action-item/uni-swipe-action-item')]).then(
                        n.bind(null, '2a65')
                    );
                },
                PriceDisplay: function () {
                    return n.e('components/PriceDisplay/PriceDisplay').then(n.bind(null, '6b05'));
                },
                NoData: function () {
                    return n.e('components/NoData/NoData').then(n.bind(null, 'cafe'));
                }
            };
            var o = function () {
                var that = this;
                var e =
                    (that.$createElement,
                    that._self._c,
                    that.__map(that.list, function (e, n) {
                        return {
                            $orig: that.__get_orig(e),
                            f0: that._f('productAttrsToString')(e.sku.attrs)
                        };
                    }));
                var n = that.list.length;
                that.$mp.data = Object.assign(
                    {},
                    {
                        $root: {
                            l0: e,
                            g0: n
                        }
                    }
                );
            };
            var r = [];
        },
        '559b': function (t, e, n) {
            'use strict';

            (function (t) {
                var i = n('4ea4');
                Object.defineProperty(e, '__esModule', {
                    value: true
                });
                e.default = void 0;
                var o = i(n('9523'));
                var r = n('26cb');
                function c(t, e) {
                    var n = Object.keys(t);
                    if (Object.getOwnPropertySymbols) {
                        var i = Object.getOwnPropertySymbols(t);
                        if (e) {
                            i = i.filter(function (e) {
                                return Object.getOwnPropertyDescriptor(t, e).enumerable;
                            });
                        }
                        n.push.apply(n, i);
                    }
                    return n;
                }
                function u(t) {
                    for (var e = 1; e < arguments.length; e++) {
                        if (null != arguments[e]) {
                            var n = arguments[e];
                        } else {
                            var n = {};
                        }
                        if (e % 2) {
                            c(Object(n), true).forEach(function (e) {
                                (0, o.default)(t, e, n[e]);
                            });
                        } else {
                            Object.getOwnPropertyDescriptors
                                ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n))
                                : c(Object(n)).forEach(function (e) {
                                      Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(n, e));
                                  });
                        }
                    }
                    return t;
                }
                var s = {
                    mixins: [i(n('452d')).default],
                    components: {
                        IButton: function () {
                            n.e('components/Button/index')
                                .then(
                                    function () {
                                        return resolve(n('93c4'));
                                    }.bind(null, n)
                                )
                                .catch(n.oe);
                        },
                        IInputNumber: function () {
                            n.e('components/InputNumber/index')
                                .then(
                                    function () {
                                        return resolve(n('4006'));
                                    }.bind(null, n)
                                )
                                .catch(n.oe);
                        }
                    },
                    data: function () {
                        return {
                            init: false,
                            list: [],
                            options: [
                                {
                                    text: '删除',
                                    style: {
                                        backgroundColor: '#F27233'
                                    }
                                }
                            ]
                        };
                    },
                    computed: u(
                        u({}, (0, r.mapGetters)(['token'])),
                        {},
                        {
                            selectedAll: function () {
                                for (t = true, e = this.list.length, n = 0, void 0; n < e; n++) {
                                    var t;
                                    var e;
                                    var n;
                                    if (!this.list[n].is_selected) {
                                        t = false;
                                        break;
                                    }
                                }
                                return t;
                            },
                            totalPrice: function () {
                                var t = {
                                    money_price: 0,
                                    score_price: 0
                                };
                                this.list.forEach(function (e) {
                                    if (e.is_selected) {
                                        t.money_price += (e.sku.discount_money_price || e.sku.money_price) * e.total;
                                        t.score_price += (e.sku.discount_score_price || e.sku.score_price) * e.total;
                                    }
                                });
                                return t;
                            }
                        }
                    ),
                    onLoad: function () {
                        this.$visitor.record('cart');
                    },
                    onShow: function () {
                        var that = this;
                        if (this.token) {
                            this.init ||
                                t.showLoading({
                                    title: '加载中'
                                });
                            this.$api.emit('product.cart.index').then(function (n) {
                                t.hideLoading();
                                that.init = true;
                                n.data.list.forEach(function (t) {
                                    t.is_selected = !!t.is_selected && t.is_selected;
                                    t.temp_total = t.total;
                                });
                                that.list = n.data.list;
                            });
                        }
                    },
                    methods: {
                        toProductPage: function (e) {
                            t.navigateTo({
                                url: '/pages/productDetail/index?uuid=' + e.sku.product.uuid
                            });
                        },
                        gotoProductDetail: function (e) {
                            var n = e.currentTarget.dataset.index;
                            t.navigateTo({
                                url: '/pages/productDetail/index?uuid=' + this.list[n].sku.product.uuid
                            });
                        },
                        payByCart: function () {
                            var e = [];
                            this.list.forEach(function (t) {
                                if (t.is_selected) {
                                    e.push({
                                        id: t.sku.id,
                                        total: t.total
                                    });
                                }
                            });
                            if (e.length) {
                                t.navigateTo({
                                    url: '/pages/orderPreview/index?skus=' + JSON.stringify(e) + '&_source=cart'
                                });
                            }
                        },
                        deleteAction: function (e) {
                            var that = this;
                            var i = this.list[e];
                            t.showLoading({
                                title: '删除中'
                            });
                            this.$http('/cart-items/' + i.uuid, 'DELETE').then(function (i) {
                                that.list.splice(e, 1);
                                t.hideLoading();
                            });
                        },
                        totalChange: function (t, e) {
                            if (t !== this.list[e].total) {
                                this.list[e].total = t;
                            }
                        },
                        selectIconType: function (t) {
                            return t ? 'success' : 'circle';
                        },
                        selectIconColor: function (t) {
                            return t ? '#303133' : '';
                        },
                        handleSelectedChange: function (t) {
                            var e = t.currentTarget.dataset.index;
                            this.list[e].is_selected = !this.list[e].is_selected;
                        },
                        handleSelectedAll: function () {
                            var t = !this.selectedAll;
                            this.list.forEach(function (e) {
                                e.is_selected = t;
                            });
                        }
                    }
                };
                e.default = s;
            }.call(this, n('543d').default));
        },
        '6b32': function (t, e, n) {
            'use strict';

            (function (t, e) {
                var i = n('4ea4');
                n('18ba');
                i(n('66fd'));
                var o = i(n('70e7'));
                t.__webpack_require_UNI_MP_PLUGIN__ = n;
                e(o.default);
            }.call(this, n('bc2e').default, n('543d').createPage));
        },
        '70e7': function (t, e, n) {
            'use strict';

            n.r(e);
            var i = n('145c');
            var o = n('7dae');
            for (var r in o) {
                if (['default'].indexOf(r) < 0) {
                    (function (t) {
                        n.d(e, t, function () {
                            return o[t];
                        });
                    })(r);
                }
            }
            n('759d');
            var c = n('f0c5');
            var u = Object(c.a)(o.default, i.b, i.c, false, null, '408d7d64', null, false, i.a, void 0);
            e.default = u.exports;
        },
        '759d': function (t, e, n) {
            'use strict';

            var i = n('b627');
            n.n(i).a;
        },
        '7dae': function (t, e, n) {
            'use strict';

            n.r(e);
            var i = n('559b');
            var o = n.n(i);
            for (var r in i) {
                if (['default'].indexOf(r) < 0) {
                    (function (t) {
                        n.d(e, t, function () {
                            return i[t];
                        });
                    })(r);
                }
            }
            e.default = o.a;
        },
        b627: function (t, e, n) {}
    },
    [['6b32', 'common/runtime', 'common/vendor']]
]);
</script>
<style>
@import './index.css';
</style>
